package com.atlin.beaconsapiclientsdk.util;

import cn.hutool.crypto.digest.DigestAlgorithm;
import cn.hutool.crypto.digest.Digester;

/**
 * @author atlin
 * @description 签名工具类
 * @createDate 2024/12/7 15:53
 */
public class SignUtil {

    /**
     * 生成签名
     *
     * @param body      包含需要签名的参数的hash映射
     * @param secretKey 秘钥
     * @return 生成的签名字符串
     */
    public static String genSign(String body, String secretKey) {
        Digester digester = new Digester(DigestAlgorithm.SHA256);
        String content = (body == null ? "" : body) + '.' + secretKey;
        return digester.digestHex(content);
    }
}
